<?php
/**
 * @author GhostWei
 * @date 2012-5-31
 */
class picture_special_category_concept extends system_concept_abstract {
	
	public function __construct($lang) {
		parent::__construct(array('lang' => $lang), array('lang = ?' => $lang));
	}
	
	public function init() {
		$this->setModel('picture_special_category_model', 'special_category');
		$this->setModelCols('special_category', array('lang', 'special_id', 'category_id'));
	}

	public function save($row) {
		$row->set('category_id', intval($row->get('category_id')));
		$row->set('special_id', intval($row->get('special_id')));
		
		if($row->getCategoryId() && $row->getSpecialId() && 
				!$this->fetch(array('category_id' => $row->getCategoryId(), 'special_id' => $row->getSpecialId()))) {
			$this->getModel('special_category')->insert($row->getModelData('special_category'));
		}
		return $row;
	}

}
